var StockInfo = function (stock, type) {
  BaseModel.call(this);
  var self = this;

  var fn = {
    initData: function (stock, type) {
      var fields = ['materialCode', 'materialName', 'model', 'providerName', 'color', 'count', 'feedUseCount', 'notInCount', 'unit'];
      self.setDataFromObj(stock, fields);

      var stockCount = stock.count + stock.notInCount - stock.feedUseCount;
      var safetyStock,limitCount;
      if (type === 'max') {
        safetyStock = stock.safetyStockMax;
        limitCount = stockCount - safetyStock;
      } else if (type === 'min') {
        safetyStock = stock.safetyStockMin;
        limitCount = safetyStock - stockCount;
      }
      limitCount = _.round(limitCount, 4);
      self.safetyStock = safetyStock;
      self.limitCount = limitCount;

      var dayCount = stock.type;
      self.dayCount = dayCount;

      var dayType;
      if (dayCount >= 365) {
        dayType = 3;
      } else if (dayCount >= 182) {
        dayType = 2;
      } else if (dayCount >= 90) {
        dayType = 1;
      } else {
        dayType = '';
      }
      self.dayType = dayType;
    }
  };

  fn.initData(stock, type);
};
